namespace SimpleWebServices
{
    using System;

    public sealed class ImplementationTest<T> : ITestExpectation
    {
        public Type Interface
        {
            get;
            set;
        }

        public bool Check()
        {
            if (null == this.Interface)
            {
                if (0 != typeof(T).GetInterfaces().Length)
                {
                    throw new TestException(string.Concat(typeof(T).Name, " unexpectedly implements at least one interface."));
                }
            }
            else
            {
                if (!typeof(T).Implements(this.Interface))
                {
                    throw new TestException(string.Concat(typeof(T).Name, " does not implement ", this.Interface.Name, "."));
                }
            }

            return true;
        }
    }
}